<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table">
<div class="content-table-title"><?=$this->title?></div>
<br />
<?php if($this->msg):?>
<div class="replace"><?=$this->msg?></div>
<br />
<?php endif;?>
<form action="/reports/city-list" name="form1" method="GET">
省份：<select name="province_id" id="province_id" onchange="GetCities(this.options[this.options.selectedIndex].value);">
					<option value="">不限</option>
					<?php if(!empty($this->provinces)):?>
					<?php foreach($this->provinces as $provinceId => $provinceName):?>
					<option value="<?=$provinceId?>" <?php if($provinceId == $this->province_id){echo "selected='selected'";}?>><?=$provinceName?></option>
					<?php endforeach;?>
					<?php endif;?>
				</select>
&nbsp;&nbsp;
城市：<select name="city_id" id="city_id">
	<option value="">不限</option>
		<?php if(!empty($this->init_cities)):?>
		<?php foreach($this->init_cities as $init_cities):?>
		<option value="<?=$init_cities['cityId']?>" <?php if($init_cities['cityId']==$this->city_id){echo "selected='selected'";}?>><?=$init_cities['cityName']?></option>
		<?php endforeach;?>
		<?php endif;?>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" class="button" value="搜索" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="button-cancle" value="清空搜索条件" onclick="location.href='?';" />
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?=$this->export_link?>" class="middle blue awesome">导出报表</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<font color="red"><b>当前搜索结果: <?=$this->data['ct']?></b></font>
</form>
<br />
<table style="width: 100%">
  <tr>
    <th>城市</th>
    <th>经销商数量</th>
    <th>汇销宝开通量</th>
    <th>汇销宝开通率</th>
    <th><a title="每周登陆7次商家数 / 开通汇销宝商家数">活跃率 *</a></th>
  </tr>
  <?php $data = $this->data['current_page_info'];?>
  <?php foreach($data as $city_id => $info):?>
  <tr>
    <td><?=$info['city_name']?></td>
    <td><?=$info['dealer_total']?></td>
    <td><?=$info['hxb_total']?></td>
	<td><?php if($info['dealer_total']){echo round($info['hxb_total']/$info['dealer_total']*100,0)."%";}else{echo "-";}?></td>
    <td><?php if($info['hxb_total']){echo round($info['hxb_active']/$info['hxb_total']*100,0)."%";}else{echo "-";}?></td>
  </tr>
  <?php endforeach;?>
</table>

<br /><br />
<div align="right"><?=$this->pagination?></div>
<br /><br /><br />

<script>
function GetCities(provinceId)
{
	$.ajax({
			type: "post",
			url : "/ajax/get-cities",
			dataType:'json',
            async:false,
			data: {
					'provinceId':provinceId,
					'type':2
				  },
				success: function(json){
					if(json.result == 1 && typeof(json.data) != "undefined") {
                        var arr = json.data;
						var txt = "<option value=''>不限</option>";
						
                        for(i=0; i < arr.length; i++){
							txt += "<option value='" + arr[i]['cityId'] + "'>" + arr[i]['cityName'] + "</option>";
                        }
						
						document.getElementById("city_id").innerHTML = txt;
                    }
			}
		});
}
</script>